# -*- coding : utf_8 -*-
'''
=======================================
Time : 2025/3/14 22:36
Author : 田霄汉
Email : 522989570@qq.com
File : ini_util.py
Project : pytest_demo
=======================================
'''

import configparser
import os
from config.setting import file_path

# local_path =os.path.join(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")), "globalconfig")

class IniUtil:

    def read_ini(self, ini_name, section, key):
        """
        读取ini配置文件
        :param section: ini中的节点
        :param key: 节点中的key
        :return: key对应的value
        """

        config = configparser.ConfigParser()
        ini_path = os.path.abspath(os.path.join(file_path['globalconfig'], ini_name))
        try:
            config.read(filenames=ini_path)
            value = config.get(section, key)
            return value
        except Exception as E:
            print("报错信息：{}".format(E))